// 引入axios实例
import request from '@/utils/request'
export default {
  // 讲师模块的curd
  // 7.更新讲师
  updateTeacher(teacher) {
    return request({
      url: `/admin/edu/teacher/update`,
      method: 'put',
      data: teacher
    })
  },
  // 6.根据id查询讲师
  getTeacherById(id) {
    return request({
      url: `/admin/edu/teacher/get/${id}`,
      method: 'get'
    })
  },
  // 5.批量删除讲师列表
  teacherBatchRemove(idsStr) {
    return request({
      url: `/admin/edu/teacher/batchRemove`,
      method: 'delete',
      params: { 'ids': idsStr } // 转为json
    })
  },
  // 4.删除讲师
  teacherRemoveById(id) {
    return request({
      url: `/admin/edu/teacher/remove/${id}`,
      method: 'delete'
    })
  },

  // 3.新增讲师
  teacherSave(teacher) {
    return request({
      url: '/admin/edu/teacher/save',
      method: 'post',
      data: teacher
    })
  },
  // 2.查询讲师分页数据
  teacherPage(pageNum, pageSize, teacherQuery) {
    return request({
      url: `/admin/edu/teacher/list/${pageNum}/${pageSize}`,
      method: 'get',
      // 路径参数，URL后拼接参数，请求体中的json字符串
      params: teacherQuery // axios会自动拼接参数到URL路径后使用
      // data:teacherQuery // @RequestBody将teacherQuery对象以json字符串的方式使用请求体提交
    })
  },
  // 1.查询所有讲师
  teacherList() {
    return request({
      url: '/admin/edu/teacher/list',
      method: 'get'
    })
  }
}
